unit RComboio2;

interface
                                          
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, RLReport, StdCtrls;

type
  TFormRComboio2 = class(TForm)
    RLReport1: TRLReport;
    RLBand1: TRLBand;
    RLGroup1: TRLGroup;
    RLBand2: TRLBand;
    RLGroup2: TRLGroup;
    RLBand3: TRLBand;
    RLLabel1: TRLLabel;
    RLLabel2: TRLLabel;
    RLDBText23: TRLDBText;
    RLDBText26: TRLDBText;
    RLLabel30: TRLLabel;
    RLLabel31: TRLLabel;
    RLDBText27: TRLDBText;
    RLDBText28: TRLDBText;
    RLDBText30: TRLDBText;
    RLDBText31: TRLDBText;
    RLDBText32: TRLDBText;
    RLLabel33: TRLLabel;
    RLLabel34: TRLLabel;
    RLLabel9: TRLLabel;
    RLImage1: TRLImage;
    RLLabel22: TRLLabel;
    RLLabel23: TRLLabel;
    RLLabel25: TRLLabel;
    RLLabel26: TRLLabel;
    RLLabel27: TRLLabel;
    RLLabel28: TRLLabel;
    RLLabel40: TRLLabel;
    RLDBText1: TRLDBText;
    RLLabel41: TRLLabel;
    RLBand4: TRLBand;
    RLLabel5: TRLLabel;
    RLLabel6: TRLLabel;
    RLLabel7: TRLLabel;
    RLLabel8: TRLLabel;
    RLDBText5: TRLDBText;
    RLDBText4: TRLDBText;
    RLDBText7: TRLDBText;
    RLDBText17: TRLDBText;
    RLLabel17: TRLLabel;
    RLDBText15: TRLDBText;
    RLLabel24: TRLLabel;
    RLLabel32: TRLLabel;
    RLDBText29: TRLDBText;
    RLLabel36: TRLLabel;
    RLDBText33: TRLDBText;
    RLDBText9: TRLDBText;
    RLDBText2: TRLDBText;
    RLLabel10: TRLLabel;
    RLLabel12: TRLLabel;
    RLLabel13: TRLLabel;
    RLLabel14: TRLLabel;
    RLLabel15: TRLLabel;
    RLDBText8: TRLDBText;
    RLDBText10: TRLDBText;
    RLDBText11: TRLDBText;
    RLLabel11: TRLLabel;
    RLLabel18: TRLLabel;
    RLLabel19: TRLLabel;
    RLDBText12: TRLDBText;
    RLDBText18: TRLDBText;
    RLDBText19: TRLDBText;
    RLLabel16: TRLLabel;
    RLDBText14: TRLDBText;
    RLLabel37: TRLLabel;
    RLMemo1: TRLMemo;
    RLLabel4: TRLLabel;
    RLDBText3: TRLDBText;
    RLDBText6: TRLDBText;
    RLLabel3: TRLLabel;
    RLLabel38: TRLLabel;
    RLLabel20: TRLLabel;
    RLDBText13: TRLDBText;
    RLLabel39: TRLLabel;
    RLDBText20: TRLDBText;
    RLLabel42: TRLLabel;
    RLDBText21: TRLDBText;
    RLLabel43: TRLLabel;
    RLDBText22: TRLDBText;
    RLLabel44: TRLLabel;
    RLDBText24: TRLDBText;
    RLLabel45: TRLLabel;
    RLDBText25: TRLDBText;
    RLLabel46: TRLLabel;
    RLLabel47: TRLLabel;
    RLDBText35: TRLDBText;
    RLLabel48: TRLLabel;
    RLDBText36: TRLDBText;
    RLLabel49: TRLLabel;
    RLDBText37: TRLDBText;                           
    RLDraw1: TRLDraw;
    RLLabel50: TRLLabel;
    RLMemo2: TRLMemo;
    RLLabel21: TRLLabel;
    RLDBText16: TRLDBText;
    RLMemo3: TRLMemo;
    RLLabel35: TRLLabel;
    RLLabel29: TRLLabel;
    RLDBText34: TRLDBText;
    RLDBText38: TRLDBText;
    RLBand6: TRLBand;
    RLDraw3: TRLDraw;
    RLDraw4: TRLDraw;
    RLDraw5: TRLDraw;
    RLDraw6: TRLDraw;
    RLLabel53: TRLLabel;
    RLLabel55: TRLLabel;
    RLDBText41: TRLDBText;
    RLLabel56: TRLLabel;
    RLLabel57: TRLLabel;
    RLDBText42: TRLDBText;
    RLDBText43: TRLDBText;
    RLDBText40: TRLDBText;
    RLLabel59: TRLLabel;
    RLLabel60: TRLLabel;
    RLDBText46: TRLDBText;
    RLDBText47: TRLDBText;
    RLLabel61: TRLLabel;
    RLDBText45: TRLDBText;
    RLLabel58: TRLLabel;
    RLLabel62: TRLLabel;
    RLDBText48: TRLDBText;
    RLLabel63: TRLLabel;
    RLLabel64: TRLLabel;
    RLLabel65: TRLLabel;
    RLLabel66: TRLLabel;
    RLDraw8: TRLDraw;
    RLDraw9: TRLDraw;
    RLDraw7: TRLDraw;
    RLLabel54: TRLLabel;
    RLLabel52: TRLLabel;
    RLGroup3: TRLGroup;
    RLBand5: TRLBand;
    RLLabel72: TRLLabel;
    RLDraw14: TRLDraw;
    RLDraw2: TRLDraw;
    RLDraw10: TRLDraw;
    RLDraw11: TRLDraw;
    RLDraw12: TRLDraw;
    RLDraw13: TRLDraw;
    RLLabel51: TRLLabel;
    RLLabel67: TRLLabel;
    RLLabel68: TRLLabel;
    RLLabel69: TRLLabel;
    RLLabel70: TRLLabel;
    RLLabel71: TRLLabel;
    RLLabel73: TRLLabel;
    RLLabel74: TRLLabel;
    RLLabel75: TRLLabel;
    procedure RLBand2BeforePrint(Sender: TObject; var PrintIt: Boolean);
    procedure RLBand1BeforePrint(Sender: TObject; var PrintIt: Boolean);
    procedure RLLabel26BeforePrint(Sender: TObject; var Text: String;
      var PrintIt: Boolean);
    procedure RLLabel27BeforePrint(Sender: TObject; var Text: String;
      var PrintIt: Boolean);
    procedure RLBand3BeforePrint(Sender: TObject; var PrintIt: Boolean);
    procedure RLDBText7BeforePrint(Sender: TObject; var Text: String;
      var PrintIt: Boolean);
    procedure RLDBText20BeforePrint(Sender: TObject; var Text: String;
      var PrintIt: Boolean);
    procedure RLDBText4BeforePrint(Sender: TObject; var Text: String;
      var PrintIt: Boolean);
  private
    { Private declarations }
    procedure GetItensSeg (codveiculo : integer; var memo : trlmemo);
  public
    { Public declarations }
  end;

var
  FormRComboio2: TFormRComboio2;

implementation

uses DMR, Geral, ZAbstractRODataset, DB;

{$R *.dfm}

procedure TFormRComboio2.RLBand2BeforePrint(Sender: TObject;
  var PrintIt: Boolean);
begin
    PrintIt := False;
end;

procedure TFormRComboio2.RLBand1BeforePrint(Sender: TObject;
  var PrintIt: Boolean);
begin
    if (GetParametro('LOGO') <> '') and ((pos('BMP',UpperCase(GetParametro('LOGO'))) > 0) or (pos('JPG',UpperCase(GetParametro('LOGO'))) > 0))then
        RLImage1.Picture.LoadFromFile(GetParametro('LOGO'));
end;

procedure TFormRComboio2.RLLabel26BeforePrint(Sender: TObject;
  var Text: String; var PrintIt: Boolean);
begin
    Text := DMRel.dsRelat.DataSet.FieldByName('DATA').AsString;
end;

procedure TFormRComboio2.RLLabel27BeforePrint(Sender: TObject;
  var Text: String; var PrintIt: Boolean);
begin
    Text := DMRel.dsRelat.DataSet.FieldByName('CODCOMBOIO').AsString;
end;

procedure TFormRComboio2.RLBand3BeforePrint(Sender: TObject;
  var PrintIt: Boolean);
begin
    with DMRel.QueryRRotaComboio do
    begin
        while NOT DMRel.QueryRRotaComboio.Eof do
        begin
            RLMemo2.Lines.Add(DMRel.QueryRRotaComboio.FieldByname('DESCRICAO').AsString);
            next;
        end;
    end;
    GetItensSeg(DMRel.dsRelat.DataSet.fieldbyname('codveiculo').AsInteger, rlmemo1);
    GetItensSeg(DMRel.dsRelat.DataSet.fieldbyname('codcarreta1').AsInteger, rlmemo3);
    GetItensSeg(DMRel.dsRelat.DataSet.fieldbyname('codcarreta2').AsInteger, rlmemo3);
    GetItensSeg(DMRel.dsRelat.DataSet.fieldbyname('codcarreta3').AsInteger, rlmemo3);
end;

procedure TFormRComboio2.RLDBText7BeforePrint(Sender: TObject;
  var Text: String; var PrintIt: Boolean);
begin
    Text := FormataFone(text);
end;

procedure TFormRComboio2.RLDBText20BeforePrint(Sender: TObject;
  var Text: String; var PrintIt: Boolean);
begin
Text := FormataFone(text);
end;

procedure TFormRComboio2.RLDBText4BeforePrint(Sender: TObject;
  var Text: String; var PrintIt: Boolean);
begin
Text := FormataFone(text);
end;

procedure TFormRComboio2.GetItensSeg(codveiculo: integer;
  var memo: trlmemo);
begin
    with DMRel.QueryRComboioItensSeg do
    begin
        close;
        ParamByName('pcod').AsInteger := codveiculo;
        open;
        while NOT DMRel.QueryRComboioItensSeg.Eof do
        begin
            memo.Lines.Add(DMRel.QueryRComboioItensSeg.FieldByname('DESCRICAO').AsString);
            next;
        end;
    end;
end;

end.
